#!/usr/bin/env python
# coding=utf8

import fontforge
from argparse import ArgumentParser

# Setup and parse the comand-line arguments
parser = ArgumentParser()
parser.add_argument("--input", help="input file name")
parser.add_argument("--output", help="output file name")
parser.add_argument("--name", help="font name")
parser.add_argument("--version", help="(optional) text to add to the existing version")
args = parser.parse_args()

# Open the file
delugia=fontforge.open(args.input)

# Rename the file
delugia.fontname="{}-Regular".format(args.name).replace(" ", "")
delugia.familyname=args.name
delugia.fullname=args.name
delugia.appendSFNTName("English (US)", "Preferred Family", args.name)
delugia.appendSFNTName("English (US)", "Compatible Full", args.name)
delugia.appendSFNTName("English (US)", "UniqueID", "{} Regular".format(args.name))
delugia.appendSFNTName("English (US)", "Trademark", "")

# Mix our version information in
delugia.sfntRevision = None # Auto-set (refreshed) by fontforge
delugia.appendSFNTName("English (US)", "Version", args.version)
delugia.version = args.version

# Save
delugia.generate(args.output)
print("Generated '{}' from {} version {}".format(args.output, args.name, args.version))
